#ifndef _I2C_SLAVE_H
#define _I2C_SLAVE_H

#define	ST_NO_REG	0	//	 No register address yet set for transaction
#define	ST_RDY_ADDR	1	//	 Ready to receive the address of the register to be used
#define	ST_REG_ADDR	2	//	 Have received register address, ready for TX/RX
#define	ST_TX_REG	3	//	 master asked for contents - transmitting register
#define	ST_RX_REG	4	//	 master is writing contents - receiving register

#define	EV_STR_RX	0	//	 USCIAB0RX	 UCSTTIFG=1, UCTR=0 (receiver)
#define	EV_STR_TX	1	//	 USCIAB0RX	 UCSTTIFG=1, UCTR=1 (transmitter)
#define	EV_STP		2	//	 USCIAB0RX	 UCSTPIFG=1
#define	EV_RX		3	//	 USCIAB0TX	UCB0RXIFG=1
#define	EV_TX		4	//	 USCIAB0TX

#define	SET_NACK	UCB0CTL1 |= UCTXNACK

#define	RX_TX_BUF_LEN	8	// bytes in RX/TX buffer

void	RX_callback(unsigned char reg, unsigned char* data, short int data_len);
short int	TX_callback(unsigned char reg, unsigned char* data);
void	init_i2c_slave(unsigned char my_addr);

#endif

